﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
namespace ZLDC.Estate.UserControl
{
    public partial class HousingControlSelect21 : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {


                hIsUsage.Value = ZLDC.Common.Estate._Session.GetSession("isUsage");                        // 用于前台列表动态列 0表示登录者为住宅业务员 1表示登录者为商铺业务员
                string UsageTypeIDList = ZLDC.Common.Estate._Session.GetSession("UsageTypeIDList");        // 如1,4 表示 住宅、商住的权限(1住宅 2商铺 3写字楼 4商住 5仓库 6厂房 7地皮 8项目盘 9其他* 10民房)
                ZLDC.Common.BaseUser.Param info = new ZLDC.Common.BaseUser.Param();
                // 1 超级管理员
                if (info.m_sRoleID != "1")
                {
                    // 根据登录的用户类型 0表示登录者为住宅业务员 1表示登录者为商铺业务员
                    if (hIsUsage.Value == "0")
                        rbUsageType1.Checked = true;
                    else
                        rbUsageType3.Checked = true;

                    // 根据用户授权的用途权限，默认选中哪个类别  rbUsageType1住宅 rbUsageType2写字楼 rbUsageType3商铺 rbUsageType4厂房 rbUsageType5民房  
                    if (UsageTypeIDList.Contains("1"))
                        rbUsageType1.Visible = true;
                    if (UsageTypeIDList.Contains("3"))
                        rbUsageType2.Visible = true;
                    if (UsageTypeIDList.Contains("2"))
                        rbUsageType3.Visible = true;
                    if (UsageTypeIDList.Contains("6"))
                        rbUsageType4.Visible = true;
                    if (UsageTypeIDList.Contains("10"))
                        rbUsageType5.Visible = true;
                  
                    int typeid = ZLDC.Common.Estate._Request.GetInt("typeid", 0);
                    if (typeid == 3)//我的盘源显示出所有类型
                    {
                        rbUsageType1.Visible = true;
                        rbUsageType2.Visible = true;
                        rbUsageType3.Visible = true;
                        rbUsageType4.Visible = true;
                        rbUsageType5.Visible = true;
                    }
                }
                else
                {
                    rbUsageType1.Visible = true;
                    rbUsageType2.Visible = true;
                    rbUsageType3.Visible = true;
                    rbUsageType4.Visible = true;
                    rbUsageType5.Visible = true;
                }

                string usage =ZLDC.Common.Estate._Request.GetString("usage");
                if (usage.Contains("1,4"))
                {
                    rbUsageType1.Checked = true;
                    rbUsageType2.Checked = false;
                    rbUsageType3.Checked = false;
                    rbUsageType4.Checked = false;
                    rbUsageType5.Checked = false;
                }
                else if (usage.Contains("3,4"))
                {
                    rbUsageType2.Checked = true;
                    rbUsageType1.Checked = false;
                    rbUsageType3.Checked = false;
                    rbUsageType4.Checked = false;
                    rbUsageType5.Checked = false;
                }
                else if (usage.Contains("2"))
                {
                    rbUsageType3.Checked = true;
                    rbUsageType1.Checked = false;
                    rbUsageType2.Checked = false;
                    rbUsageType4.Checked = false;
                    rbUsageType5.Checked = false;
                }
                else if (usage == "6")
                {
                    rbUsageType4.Checked = true;
                    rbUsageType1.Checked = false;
                    rbUsageType2.Checked = false;
                    rbUsageType3.Checked = false;
                    rbUsageType5.Checked = false;
                }
                else if (usage == "10")
                {
                    rbUsageType5.Checked = true;
                    rbUsageType1.Checked = false;
                    rbUsageType2.Checked = false;
                    rbUsageType3.Checked = false;
                    rbUsageType4.Checked = false;
                }
                LoadCity2();
            }
        }
        /// <summary>
        /// 加载城区
        /// </summary>
        private void LoadCity2()
        {
            ZLDC.Topo.BLL.Estate.AreaBLL.LoadCity(sCity2, 1);
            ListItem item1 = new ListItem("全部", "0");
            sCity2.Items.Insert(0, item1);
        }
    }
}